package com.yanqu.road.server.cmd.activity.chuhan;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ChuHanProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.chuhan.CrossChuHanMgr;
import com.yanqu.road.server.manager.activity.chuhan.activity.CrossChuHanActivity;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.server.protocol.CrossProtocol;

@Cmd(code = CrossProtocol.C2_CHUHAN_LOGIN, desc = "")
public class CrossChuHanLoginCmd extends CrossUnionCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ChuHanProto.CrossChuHanLoginReqMsg reqMsg = ChuHanProto.CrossChuHanLoginReqMsg.parseFrom(packet.getBytes());

        // 更新userBaseInfo
        UserBaseInfo userBaseInfo = PlayerBasePb.parseBaseUserInfo(reqMsg.getUserBaseInfo());
        CrossUserMgr.updateUserBaseInfo(packet.getPlayerId(), userBaseInfo);

        CrossChuHanActivity activity = CrossChuHanMgr.getActivity(reqMsg.getActivityId(), groupId);
        if (activity == null) {
            return true;
        }
        activity.loginByCmd(packet.getPlayerId(), reqMsg);
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
